<template>
    <div>
      <div v-for="(item, index) in menuData" :key="index">
        <el-submenu 
          :index="item.id + ''"
          v-if="item.childMenus && item.childMenus.length > 0"
          :key="item.id + ''"
        >
          <template slot="title">
            <i :class="item.icon"></i>
            <span slot="title" style="color: azure;">{{ item.menuName }}</span>
          </template>
          <Menu :menuData="item.childMenus"></Menu>
        </el-submenu>
        <el-menu-item 
          v-else
          :index="item.url + ''"
          :route="item.url"
          :key="item.id + ''"
        >
          <i :class="item.icon"></i>
          <span>{{ item.menuName }}</span>
        </el-menu-item>
      </div>
    </div>
</template>

<script>
export default {//父子组件传参
    name: "Menu",
    props: {
      menuData: {
        type: Array,
        default: () => {
          return [];
        },
      },
    },
}
</script>

<style>
 .el-menu--collapse span,
  .el-menu--collapse i.el-submenu__icon-arrow {
    height: 0;
    width: 0;
    overflow: hidden;
    visibility: hidden;
    display: inline-block;
    /* background-color: black;
    color: aliceblue; */
  }
</style>